#ifndef __MyString__
#define __MyString__
#include <iostream>
using namespace std;
class MyString
{
private:
	char* s;
	
	int size;      //当前的数组空间大小
	int expansion; //每次拓展的空间大小

	char* Expand(int need_space); //空间拓展
	void ConstructWithChar(const char*);//用于以char构造对象


public:
	int num_of_s;  //当前字符个数


	MyString(/* args */);
	MyString(const char&);
	MyString(const char*);
	MyString(const MyString&);
	~MyString();

	MyString& operator=(const char*);
	MyString& operator=(const MyString&);
	friend ostream& operator<<(ostream&, const MyString&);
	friend istream& operator>>(istream&, MyString&);
	friend MyString operator+(const MyString&, const MyString&);
	
	char operator[](const int& index);
	friend bool operator==(const MyString&, const MyString&);
	friend bool operator<(const MyString&, const MyString&);

	//找到对应匹配字符串的第一个下标
	int Find(const MyString&, int start_index = 0);
	//找到对应匹配字符串的第nth个下标
	int Findnth(const MyString&, int nth = 1, int start_index = 0);

	//将[start_index,end_index)的字符串转为对应字符串
	MyString instead(int start_index, int end_index, const MyString&);
	MyString instead(int start_index, const MyString&);

	// 将英文字母转成小写
	void lower_case();

	// 返回一个从start_indx开始的长度为length的字符串
	MyString substr(int start_index, int length);
	//截取到末尾
	MyString substr(int start_index);

	// 将字符串转为int
	int toint();

	//从start_index开始计算对应字符有多少个
	int count(const char&, int start_index = 0);
};

#endif